package com.shu.es;

import com.shu.utils.HttpUtils;

public class EsReindex {

	public static void main(String[] args) throws Exception {
		EsReindex.reindex("first_scale_weight20180221");
	}
	
	public static void reindex(String index) {
		String mainEsUrl = "http://172.18.245.104:9200";
		String paramter = "{\"source\": {  \"remote\": { \"host\": \""+mainEsUrl+"\"" + " },\"index\": \""+index+"\"  },  \"dest\": { \"index\": \""+index+"\"}}";
		String reindexUrl = "http://127.0.0.1:9201/_reindex?wait_for_completion=false";
		System.out.println("The paramter is "+paramter);
		String info = HttpUtils.sendPost(reindexUrl, paramter);
		System.out.println("The result is "+info);
	}
	
	
	public static void get() {
		String s = HttpUtils.sendGet("http://127.0.0.1:9200/_snapshot/my_backup/_all");
		System.out.println(s);
	}
}
